/**
 * @class Bible.data.BibleSearchStore
 * @extends Ext.data.ArrayStore
 */
Bible.data.BibleSearchStore = Ext.extend(Ext.data.Store, {
    constructor: function(config){
        config = config || {};
		var newObjDs = Ext.data.Record.create([
			{name: 'id', type: 'int'},
			{name: 'bnumber', type: 'int'},
			{name: 'cnumber', type: 'int'},
			{name: 'vnumber', type: 'int'},
			{name: 'text', type: 'string'},
			{
				name: 'verse',
				type: 'string',
				convert: function(v, r){
					var verse = Bible.records.books[r[1]-1][1] + ' ' + r[2]+':'+ r[3];
					return verse;
				}
		   }
		]);
		
		Ext.applyIf(config, {
			proxy: new Ext.data.HttpProxy(new Ext.data.Connection({
				method: 'GET',
				url: 'servlets/chapters.php'
				//autoAbort: true
			})),
			baseParams: {
				type: 'all',
				book: '',
				action: 'search',
				limit: 10
			},
			remoteSort: true,
			reader: new Ext.data.ArrayReader({
				totalProperty: 'total',
				root: 'data',
				idIndex: 0
			}, newObjDs),
			sortInfo: {
				field: 'id',
				direction: 'ASC'
			}
        });
        Bible.data.BibleSearchStore.superclass.constructor.call(this, config);
    }
});
